package com.wwy.arithmetic.suanfa;

import com.wwy.arithmetic.suanfa.entry.TreeNode;

/**
 * 查看二叉树是否对称
 */
public class DuiChenTree {


    public static boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        } else if (p == null || q == null) {
            return false;
        } else if (p.getVal() != q.getVal()) {
            return false;
        }else{
            return isSameTree(p.getLeft(),q.getLeft())&& isSameTree(q.getRight(),p.getRight());
        }
    }
}
